package com.example.demo.service;

import com.example.demo.dao.OrderDAO;
import com.example.demo.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    private OrderDAO orderDAO;

    public List<Order> findOrders(int userid)
    {
        return orderDAO.findOrders(userid);
    }

    public void deleteOrder(Order order)
    {
         orderDAO.deleteOrder(order);
    }

    public void insertOrderAndId(Order order)
    {
        orderDAO.insertOrderAndId(order);
    }

    public void insertOrder(Order order)
    {
        orderDAO.insertOrder(order);
    }

    public void changeStatus(Order order)
    {
        orderDAO.changeStatus(order);
    }

    public List<Order> listOrder(int currentPage,int status){
        int start = (currentPage-1)*10;
        return orderDAO.listOrder(start,status);
    }


    public int listOrderTotal(int status){
        return orderDAO.listOrderTotal(status);
    }



}
